home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / ChipCD 6.02.iso / macos / files / ModemScN.sit / Nokia HSCSD V.110 4x RB < prev    next >
Text File  |  2001-04-10  |  7KB  |  440 lines

  1. !  Nokia HSCSD
  2. !
  3. !    Author:    Ross Barkman
  4. !
  5. !
  6. !    History:
  7. !        24 Jan 01    First release of base script
  8. !        26 Jan 01    Configured for HSCSD V.110
  9. !        10 Apr 01    Add +IFC=0,2 to overcome flow control problem
  10. !
  11. !  'mlts' resource info:
  12. !    byte 1 == 01 -> modem HAS built-in error correction protocols
  13. !    byte 2 == 01 -> modem HAS built-in data compression protocols
  14. !    byte 3 == 200 -> max number of chars in varstr 7
  15. !    byte 4 == 200 -> max number of chars in varstr 8
  16. !    byte 5 == 200 -> max number of chars in varstr 9
  17. !    
  18. @ORIGINATE
  19. @ANSWER
  20. !
  21. ! ---- Modem setup ----
  22. !
  23. @LABEL 1
  24. !
  25. ! Set serial port speed 115200, all interface signals off
  26. serreset 115200, 0, 8, 1
  27. hsreset 0 0 0 0 0 0
  28. settries 0
  29. !
  30. ! Check the phone is responding
  31. !
  32. matchclr
  33. matchstr 1 2 "OK\13\10"
  34. write "AT\13"
  35. matchread 30
  36. jump 101
  37. !
  38. ! Check the phone is a Nokia
  39. !
  40. @LABEL 2
  41. matchclr
  42. matchstr 1 3  "Nokia"
  43. write "AT+CGMI\13"
  44. matchread 60
  45. jump 109
  46. !
  47. @LABEL 3
  48. !
  49. ! Configure the phone
  50. !
  51. matchclr
  52. matchstr 1 5   "OK\13\10"
  53. matchstr 2 101 "ERROR\13\10"
  54. write "AT&FE0V1&D2&S0&C1S0=0+IFC=0,2\13"
  55. matchread 30
  56. inctries
  57. iftries 3 101
  58. jsr 7
  59. jump 3
  60. !
  61. @LABEL 5
  62. pause 20
  63. settries 0
  64. !
  65. @LABEL 6
  66. !
  67. ! Set additional options
  68. !
  69. matchclr
  70. matchstr 1 9   "OK\13\10"
  71. matchstr 2 108 "ERROR\13\10"
  72. write "AT+CBST=81,0,1;+CHSN=4,0,0,0\13"
  73. matchread 60
  74. inctries
  75. iftries 3 101
  76. jsr 7
  77. jump 6
  78. !
  79. @LABEL 7
  80. !
  81. ! Attempt to reset the phone
  82. !
  83. DTRClear
  84. pause 5
  85. DTRSet
  86. flush
  87. return
  88. !
  89. @LABEL 9
  90. !
  91. ! Setup complete
  92. !
  93. ifANSWER 32
  94. !
  95. !
  96. ! ---- Place a call ----
  97. !
  98. @LABEL 20
  99. !
  100. ! Display the full dialstring (Varstring 1)
  101. !
  102. note "Dialling ^1" 3
  103. !
  104. ! Varstrings 7, 8 and 9 may contain partial dialstrings
  105. !    if the number is longer than the phone's buffer
  106. !    (unlikely, but we allow for it)
  107. ifstr 8 27 " "
  108. ifstr 9 24 " "
  109. !
  110. !  Write dialstring in varstrings 7, 8 & 9
  111. matchclr
  112. matchstr 1 21 "OK\13\10"
  113. write "ATX5D^3^7;\13"
  114. matchread 400
  115. jump 101
  116. !
  117. @LABEL 21
  118. matchclr
  119. matchstr 1 22 "OK\13\10"
  120. write "ATX5D^3^8;\13"
  121. matchread 400
  122. jump 101
  123. !
  124. @LABEL 22
  125. write "ATX5D^3^9\13"
  126. jump 32
  127. !
  128. !
  129. @LABEL 24
  130. !  Write dialstring in varstrings 7 & 8
  131. matchclr
  132. matchstr 1 25 "OK\13\10"
  133. write "ATX5D^3^7;\13"
  134. matchread 400
  135. jump 101
  136. !
  137. @LABEL 25
  138. write "ATX5D^3^8\13"
  139. jump 32
  140. !
  141. @LABEL 27
  142. !  Write dialstring in varstring 7
  143. write "ATX5D^3^7\13"
  144. !
  145. !
  146. ! ---- Connect response ----
  147. !
  148. ! Parses successful connect responses in the following format:
  149. !   CARRIER
  150. !    +ER xxxx
  151. !    +DR yyyy
  152. !   CONNECT zzzzz
  153. !
  154. @LABEL 32
  155. matchclr
  156. matchstr  1 81  "RING\13\10"
  157. matchstr  2 102 "NO DIALTONE\13\10"
  158. matchstr  3 103 "NO CARRIER"
  159. matchstr  4 103 "ERROR\13\10"
  160. matchstr  5 104 "BUSY\13\10"
  161. matchstr  6 105 "NO ANSWER\13\10"
  162. matchstr  7 33  "CARRIER"
  163. matchstr  8 34  "CONNECT"
  164. matchstr  9 61  "+ER"
  165. matchstr 10 66  "+DR"
  166. matchread 700
  167. ifANSWER 32
  168. jump 105
  169. !
  170. !  CARRIER parsing
  171. !
  172. @LABEL 33
  173. note "Network carrier detected" 2
  174. jump 32
  175. !
  176. !  CONNECT parsing
  177. !
  178. @LABEL 34
  179. !
  180. !    2400 and 4800 have two entries each
  181. !    to distinguish them from 24000 and 48000
  182. !
  183. matchclr
  184. matchstr  1 40 "2400\13"
  185. matchstr  2 40 "2400/"
  186. matchstr  3 41 "4800\13"
  187. matchstr  4 41 "4800/"
  188. matchstr  5 42 "7200"
  189. matchstr  6 43 "9600"
  190. matchstr  7 44 "12000"
  191. matchstr  8 45 "14400"
  192. matchstr  9 46 "19200"
  193. matchstr 10 51 "28800"
  194. matchstr 11 52 "38400"
  195. matchstr 12 53 "43200"
  196. matchstr 13 54 "48000"
  197. matchstr 14 55 "56000"
  198. matchstr 15 56 "64000"
  199. matchread 10
  200. jump 59
  201. !
  202. ! -- Connection rates --
  203. !
  204. ! CommunicatingAt informs ARA of the link speed
  205. !
  206. @LABEL 40
  207. note "Communicating at 2400 bps." 2
  208. CommunicatingAt 2400
  209. jump 60
  210. !
  211. @LABEL 41
  212. note "Communicating at 4800 bps." 2
  213. CommunicatingAt 4800
  214. jump 60
  215. !
  216. @LABEL 42
  217. note "Communicating at 7200 bps." 2
  218. CommunicatingAt 7200
  219. jump 60
  220. !
  221. @LABEL 43
  222. note "Communicating at 9600 bps." 2
  223. CommunicatingAt 9600
  224. jump 60
  225. !
  226. @LABEL 44
  227. note "Communicating at 12400 bps." 2
  228. CommunicatingAt 12400
  229. jump 60
  230. !
  231. @LABEL 45
  232. note "Communicating at 14400 bps." 2
  233. CommunicatingAt 14400
  234. jump 60
  235. !
  236. @LABEL 46
  237. note "Communicating at 19200 bps." 2
  238. CommunicatingAt 19200
  239. jump 60
  240. !
  241. @LABEL 51
  242. note "Communicating at 28800 bps." 2
  243. CommunicatingAt 28800
  244. jump 60
  245. !
  246. @LABEL 52
  247. note "Communicating at 38400 bps." 2
  248. CommunicatingAt 38400
  249. jump 60
  250. !
  251. @LABEL 53
  252. note "Communicating at 43200 bps." 2
  253. CommunicatingAt 43200
  254. jump 60
  255. !
  256. @LABEL 54
  257. note "Communicating at 48000 bps." 2
  258. CommunicatingAt 48000
  259. jump 60
  260. !
  261. @LABEL 55
  262. note "Communicating at 56000 bps." 2
  263. CommunicatingAt 56000
  264. jump 60
  265. !
  266. @LABEL 56
  267. note "Communicating at 64000 bps." 2
  268. CommunicatingAt 64000
  269. jump 60
  270. !
  271. @LABEL 59
  272. note "Communicating at an unknown rate." 2
  273. !
  274. @LABEL 60
  275. jump 70
  276. !
  277. ! -- +ER (error correction reporting) parsing --
  278. !
  279. ! Userhook 2 informs ARA that a modem-to-modem error
  280. ! correcting protocol has been negotiated
  281. !
  282. @LABEL 61
  283. matchclr
  284. matchstr  1 63 "NONE"
  285. matchstr  2 62 "LAPM"
  286. matchstr  3 62 "ALT"
  287. matchstr  4 63 "\13"
  288. matchread 10
  289. jump 63
  290. !
  291. @LABEL 62
  292. note "Modem Reliable Link Established." 2
  293. userhook 2
  294. !
  295. @LABEL 63
  296. jump 32
  297. !
  298. ! -- +DR (data compression reporting) parsing --
  299. !
  300. ! Userhook 3 informs ARA that a modem-to-modem compression
  301. ! protocol has been negotiated
  302. !
  303. @LABEL 66
  304. matchclr
  305. matchstr  1 68 "NONE"
  306. matchstr  2 67 "V42B"
  307. matchstr  3 67 "MNP5"
  308. matchstr  4 68 "\13"
  309. matchread 10
  310. jump 68
  311. !
  312. @LABEL 67
  313. note "Modem Compression Established." 2
  314. userhook 3
  315. !
  316. @LABEL 68
  317. jump 32
  318. !
  319. !
  320. ! -- Normal exit after "CONNECT" --
  321. !
  322. !
  323. @LABEL 70
  324. !
  325. ! Turn CTS on, for hardware flow control
  326. !
  327. HSReset 0 1 0 0 0 0
  328. !
  329. ifANSWER 71
  330. pause 30
  331. !
  332. @LABEL 71
  333. exit 0
  334. !
  335. !
  336. ! ---- Answer calls ----
  337. !
  338. !    A RING result from the modem and in ANSWERING mode
  339. !    claims the serial port and answering the phone
  340. !
  341. @LABEL 81
  342. ifORIGINATE 32
  343. userhook 1
  344. note "Answering phone..." 2
  345. write "ATA\13"
  346. jump 32
  347. !
  348. !
  349. ! ---- Hang up and reset modem ----
  350. !
  351. @HANGUP
  352. @LABEL 90
  353. settries 0
  354. HSReset 0 0 0 0 0 0
  355. !
  356. @LABEL 92
  357. !
  358. !  Escape from data to command mode
  359. !
  360. matchclr
  361. matchstr 1 94 "OK\13\10"
  362. pause 11
  363. write "+++"
  364. matchread 20
  365. !
  366. @LABEL 94
  367. !
  368. ! Send hangup command
  369. !
  370. pause 10
  371. matchclr
  372. matchstr 1 98 "NO CARRIER\13\10"
  373. matchstr 2 98 "OK\13\10"
  374. matchstr 3 98 "ERROR\13\10"
  375. matchstr 4 98 "0\13\10"
  376. write "AT+CHUP\13"
  377. matchread 30
  378. ! If that fails, toggle DTR
  379. !
  380. DTRClear
  381. pause 5
  382. DTRSet
  383. flush
  384. !
  385. ! Try this three times only
  386. !
  387. inctries
  388. iftries 3 101
  389. jump 92
  390. !
  391. !
  392. @LABEL 98
  393. !
  394. ! Reset phone to default settings
  395. !
  396. pause 10
  397. matchclr
  398. matchstr 1 99 "OK\13\10"
  399. write "AT&F\13"
  400. matchread 30
  401. jump 101
  402. !
  403. @LABEL 99
  404. exit 0
  405. !
  406. ! ---- Error messages -----
  407. !
  408. ! Modem Not Responding
  409. @LABEL 101
  410. exit -6019
  411. !
  412. ! No Dial Tone
  413. @LABEL 102
  414. exit -6020
  415. !
  416. ! No Carrier or Error
  417. @LABEL 103
  418. exit -6021
  419. !
  420. ! Busy
  421. @LABEL 104
  422. exit -6022
  423. !
  424. ! No Answer
  425. @LABEL 105
  426. exit -6023
  427. !
  428. ! User Cancellation
  429. @LABEL 107
  430. exit -6008
  431. !
  432. @LABEL 108
  433. exit -6002 "The phone or network does not seem to support the speed or encoding type (e.g. V.110 or V.120) required for this script"
  434. !
  435. @LABEL 109
  436. exit -6002 "This script is only suitable for Nokia mobile phones"
  437.